Test Series - java script

Test Number 70/92

Q: What is necessary when we need to create a new field in craft?
A. Type of the input
B. Type of the output
C. Type of the field
D. Type of argument
Solution: Whenever someone creates a new field in Craft, they must specify what type of field it is. They are organized into Field Groups for convenience, but Field Groups have very little relevance anywhere else in the system.
Q: What does the getInputHtml() return?
A. Input
B. Fieldtype’s input HTML
C. Array
D. Value
Solution: The method getInputHtml() returns a fieldtype’s input HTML. It accepts two arguments: $name and $value.
Q: How many arguments does the getInputHtml() accept?
A. 1
B. 2
C. 3
D. 4
Solution: The method getInputHtml() returns a fieldtype’s input HTML. The method getInputHtml(0 accepts two arguments: $name and $value. $name is the name you should assign your HTML input name= attribute, and $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
Q: Which is the method used to process on the input post data before it is saved to the database?
A. prep()
B. settings()
C. defineSettings()
D. prepSettings()
Solution: defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc). If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
Q: What is the purpose of the parameter $name ?
A. Document Name
B. Input Name
C. Output Name
D. ID
Solution: getinputhtml() accepts two arguments: $name and $value. The parameter $name is the name you should assign your HTML input name= attribute.
Q: What does the method defineSettings() return?
A. Array of settings name
B. Array of hash key
C. Array of strings
D. Array of objects
Solution: The defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc). If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
Q: What is the purpose of the parameter $value?
A. Field’s expected value
B. Field’s previous value
C. Field’s current value
D. Field’s probability value
Solution: getinputhtml() accepts two arguments: $name and $value. The parameter $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
Q: When does the defineContentAttribute() method return a false?
A. Data stored in different table
B. Data stored in its own table
C. Data is not stored at all
D. Data is not obtained
Solution: If your fieldtype is storing data in its own table, and doesn’t have any use for a column within the main content table, you may also set defineContentAttribute() to return false. By default, BaseFieldType sets the column to VARCHAR(255), but you can override that with defineContentAttribute().
Q: How many events does the BaseFieldType provide?
A. 1
B. 2
C. 3
D. 4
Solution: BaseFieldType provides three events that you can latch code onto:
onBeforeSave() : Called right before a field is saved.
onAfterSave() : Called right after a field is saved, and $this->model->id is set.
onAfterElementSave() : Called right after an element is saved, and $this->element->id is set.
Q: Which method is called right before a field is saved?
A. onBeforeSave()
B. BeforeSave()
C. SaveBefore()
D. onSave()
Solution: BaseFieldType provides three events that you can latch code onto:onBeforeSave(), onAfterSave() and onAfterElementSave(). The method onBeforeSave() is called right before a field is saved.

You Have Score    /10